<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>twix | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>twix</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>twix</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/plugins/twix/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/10-plugins/05-twix.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">npm install twix
</code></pre>

							</div>
<p>&#x53E6;&#x4E00;&#x4E2A;&#x8303;&#x56F4;&#x63D2;&#x4EF6;&#x662F; Isaac Cambron &#x7684;&#x5E93; <code>Twix</code>&#x3002;
&#x5B83;&#x5177;&#x6709;&#x8BB8;&#x591A;&#x4E0E;&#x8303;&#x56F4;&#x76F8;&#x5173;&#x7684;&#x7279;&#x6027;&#xFF0C;&#x5E76;&#x4E14;&#x64C5;&#x957F;&#x683C;&#x5F0F;&#x5316;&#x8303;&#x56F4;&#x3002;
&#x4F8B;&#x5982;&#xFF0C;</p>
<pre><code class="language-javascript">var t = moment(&quot;1/25/1982 9:30 AM&quot;).twix(&quot;1/25/1982 1:30 PM&quot;);
t.isCurrent(); // false
t.count(&apos;minutes&apos;); // 241
t.format();  // &apos;Jan 25, 1982, 9:30 AM - 1:30 PM&apos;
t.simpleFormat(&quot;h:m&quot;); // &apos;9:30 - 1:30&apos;
</code></pre>
<p>&#x6240;&#x6709;&#x9009;&#x9879;&#x548C;&#x7279;&#x6027;&#x7684;&#x5B8C;&#x6574;&#x6587;&#x6863;&#x5728;<a href="javascript:window.open('http://nodejs.cn/s/jXv16S');" target="_blank" rel="nofollow">&#x8FD9;&#x91CC;</a>&#x3002;</p>
<p>&#x50CF;&#x8FD9;&#x6837;&#x5728; npm &#x4E0A;&#x53EF;&#x7528;&#xFF1A;</p>
<pre><code>npm install twix
</code></pre>
<p>&#x6216;&#x8005;&#x53EA;&#x662F;&#x4ECE;<a href="javascript:window.open('http://nodejs.cn/s/iqRf2p');" target="_blank" rel="nofollow">&#x8FD9;&#x91CC;</a>&#x83B7;&#x53D6; JS &#x6587;&#x4EF6;&#x3002;</p>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">npm install twix
</code></pre>

							</div>
<p>Another range plugin is Isaac Cambron&apos;s library <code>Twix</code>. It has many
range-related features and excels at formatting ranges readably. For example,</p>
<pre><code class="language-javascript">var t = moment(&quot;1/25/1982 9:30 AM&quot;).twix(&quot;1/25/1982 1:30 PM&quot;);
t.isCurrent(); // false
t.count(&apos;minutes&apos;); // 241
t.format();  // &apos;Jan 25, 1982, 9:30 AM - 1:30 PM&apos;
t.simpleFormat(&quot;h:m&quot;); // &apos;9:30 - 1:30&apos;
</code></pre>
<p>Full documentation of all the options and features is <a href="javascript:window.open('http://icambron.github.io/twix.js');" target="_blank" rel="nofollow">here</a>.</p>
<p>It&apos;s available on npm like so:</p>
<pre><code>npm install twix
</code></pre>
<p>Or just grab the JS file from <a href="javascript:window.open('https://raw.github.com/icambron/twix.js/master/bin/twix.js');" target="_blank" rel="nofollow">here</a>.</p>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>